import { ThemeService } from "@/shared/api/api.theme";
import { QueryClient, useQuery } from "@tanstack/react-query";



export function useGetThemeById(themeId: number) {
    const queryClient = new QueryClient
    const { isLoading, error, data, refetch, isSuccess } =
        useQuery(
            {
                queryKey: ['theme', themeId],
                queryFn: () => ThemeService.getOne(themeId),
                retry: 3
            }, queryClient
        )
    const errorMessage = error ? "Load disciplines failed" : undefined;

    return {
        isLoading,
        isSuccess,
        errorMessage,
        refetch,
        theme: data
    };
}